<?php

/**
 * InvoiceRow filter form base class.
 *
 * @package    dashboard
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseInvoiceRowFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'row_dateadded'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'row_dateordered' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'row_servicename' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_benchmark'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_newprice'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_hauler_cost' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_haul_cost'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_perton'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_tons'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_fuel_fee'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_latefee'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_adminfee'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_franchise'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_item_unit'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_item_price'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'row_item_qty'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'serv_group_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Service'), 'add_empty' => true)),
      'invoice_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Invoice'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'row_dateadded'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'row_dateordered' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'row_servicename' => new sfValidatorPass(array('required' => false)),
      'row_benchmark'   => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_newprice'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_hauler_cost' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_haul_cost'   => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_perton'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_tons'        => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_fuel_fee'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_latefee'     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_adminfee'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_franchise'   => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_item_unit'   => new sfValidatorPass(array('required' => false)),
      'row_item_price'  => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'row_item_qty'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'serv_group_id'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Service'), 'column' => 'serv_id')),
      'invoice_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Invoice'), 'column' => 'invoice_id')),
    ));

    $this->widgetSchema->setNameFormat('invoice_row_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'InvoiceRow';
  }

  public function getFields()
  {
    return array(
      'row_id'          => 'Number',
      'row_dateadded'   => 'Date',
      'row_dateordered' => 'Date',
      'row_servicename' => 'Text',
      'row_benchmark'   => 'Number',
      'row_newprice'    => 'Number',
      'row_hauler_cost' => 'Number',
      'row_haul_cost'   => 'Number',
      'row_perton'      => 'Number',
      'row_tons'        => 'Number',
      'row_fuel_fee'    => 'Number',
      'row_latefee'     => 'Number',
      'row_adminfee'    => 'Number',
      'row_franchise'   => 'Number',
      'row_item_unit'   => 'Text',
      'row_item_price'  => 'Number',
      'row_item_qty'    => 'Number',
      'serv_group_id'   => 'ForeignKey',
      'invoice_id'      => 'ForeignKey',
    );
  }
}
